#!/usr/bin env python
# -*- coding: utf-8 -*-
###########################################################################
#   Copyright (C) 2008 by Serj Poltavsky                                  #
#   serge.uliss at gmail.com                                              #
#                                                                         #
#   This program is free software; you can redistribute it and/or modify  #
#   it under the terms of the GNU General Public License as published by  #
#   the Free Software Foundation; either version 3 of the License, or     #
#   (at your option) any later version.                                   #
#                                                                         #
#   This program is distributed in the hope that it will be useful,       #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#   GNU General Public License for more details.                          #
#                                                                         #
#   You should have received a copy of the GNU General Public License     #
#   along with this program. If not, see <http://www.gnu.org/licenses/>   #
###########################################################################

class Node(list):
    def __init__(self, nodename):
        list.__init__(self)
        self.nodename = nodename

    def update(self, dom, parent):
        node = dom.createElement(self.nodename)
        parent.appendChild(node)
        return node

    def update_children(self, dom, parent):
        for child in self:
            child.update(dom, parent)


def seconds_to_str(seconds):
    import math
    msec, sec = math.modf(seconds)
    h, s = divmod(sec, 3600)
    m, s = divmod(s, 60)
    return "%02i:%02i:%02i.%02i" % (h, m, s, round(msec * 100))